/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.game;

/**
 *
 * @author Spyros
 */
public class FighterEntity extends Entity {

    private int healthPoints;
    private boolean isAtk = false;
    private boolean isDef = false;
    private boolean isRight = false;

    public FighterEntity(String ref, int x, int y, boolean isRight) {
        super("sprites/knight1.gif", x, y);
        this.isRight = isRight;
        healthPoints = GlobalStatics.maxHealthPoints;
        look();
    }

    /*
     * Method
     */
    @Override
    public void move(long delta) {
        if ((dx < 0) && (x < 0)) {
            return;
        }
        if ((dx > 0) && (x > GlobalStatics.W_WIDTH - getWidth())) {
            return;
        }

        super.move(delta);
    }
    //Initialize the sprites for each player

    public final void look() {
        if (isRight) {
            sprite = SpriteStore.get().getSprite("sprites/knight_right.gif");
        } else {
            sprite = SpriteStore.get().getSprite("sprites/knight_left.gif");
        }

    }
    //Method that replace the sprite if the player attacks.

    public void attack() {
        if (isRight) {
            sprite = SpriteStore.get().getSprite("sprites/knight_atk_right.gif");
        } else {
            int oldX = getX();
            int oldWidth = getWidth();
            sprite = SpriteStore.get().getSprite("sprites/knight_atk_left.gif");
            x = oldX - (getWidth() - oldWidth);
        }
    }

    //Method that replace the sprite if the player defends.
    public void defend() {
        if (isRight) {
            sprite = SpriteStore.get().getSprite("sprites/knight_right.gif");
        } else {
            sprite = SpriteStore.get().getSprite("sprites/knight_left.gif");
        }
    }

    /*
     * Getters setters for health points and calculation methods for
     * incrementally downsize the health amount of the enemy.
     */
    public int getHealthPoints() {
        return healthPoints;
    }

    public void setHealthPoints(int healthPoints) {
        this.healthPoints = healthPoints;
    }

    public void resetHealthPoints() {
        healthPoints = GlobalStatics.maxHealthPoints;
    }

    public void removeHP(int ammount) {
        healthPoints -= ammount;
    }

    public void addHP(int ammount) {
        healthPoints += ammount;
    }

    public boolean getIsAtk() {
        return isAtk;
    }

    public void setIsAtk(boolean isAtk) {
        this.isAtk = isAtk;
    }

    public boolean getIsDef() {
        return isDef;
    }

    public void setIsDef(boolean isDef) {
        this.isDef = isDef;
    }
}
